1

00:00:00,686  -->  00:00:08,089
In the previous video, we have done create
a script to configure multiple router at once using netmiko.

2

00:00:09,000  -->  00:00:13,817
But if we see here, the configuration is still manual,

3

00:00:14,515  -->  00:00:19,233
so we type the configuration
for loopback0 and loopback1.

4

00:00:20,435  -->  00:00:27,600
In this case, we just create 2 loopback,
the question is, how if we need to configure

5

00:00:27,600  -->  00:00:35,040
5 loopback? This is not efficient if we
configure the loopback one by one like this.

6

00:00:35,874  -->  00:00:39,440
The solution is, we can use looping.

7

00:00:40,252  -->  00:00:47,611
So now we are going to learn nested
looping, which is looping inside looping.

8

00:00:48,503  -->  00:00:51,908
The first looping is looping to the router,

9

00:00:52,240  -->  00:00:57,920
and then, for each router, we will looping
to create multiple loopback interface.

10

00:00:58,743  -->  00:01:04,377
Let’s just start. Let’s say we
will create loopback 3 until 6.

11

00:01:05,212  -->  00:01:15,000
Let’s copy this script, create new file, let’s
say the name is netmiko_looping_nested.py,

12

00:01:21,669  -->  00:01:23,748
And then paste the script.

13

00:01:24,800  -->  00:01:27,257
Here we looping to the router,

14

00:01:29,600  -->  00:01:37,817
connect to the router, and the here we have list
config to configure loopback0 and loopback 1.

15

00:01:38,880  -->  00:01:47,314
we will change this list to configure loopback 3
until 6, or actually we don’t have loopback2 yet,

16

00:01:47,726  -->  00:01:51,188
so let’s configure loopback2 until 5.

17

00:01:52,012  -->  00:01:53,897
Let’s just remove this,

18

00:01:58,297  -->  00:02:01,051
so now the list is empty,

19

00:02:01,657  -->  00:02:13,394
And then here we can define a looping, for x in
range 2 until 6, so here we looping from 2 to 5.

20

00:02:14,286  -->  00:02:18,079
And then here list_config.append,

21

00:02:18,457  -->  00:02:25,006
interface loopback, here we need to
use f string, and here we can use x.

22

00:02:27,817  -->  00:02:36,697
List_config.append, here we use
f string again, ip address 10.

23

00:02:38,389  -->  00:02:48,891
If you remember, the ip address of loopback0 is
10.1.1, the ip address of loopback1 is 10.2.2,

24

00:02:49,600  -->  00:02:59,085
So this 2 number is the loopback number
increment by 1, so here we can use x + 1,

25

00:03:06,126  -->  00:03:10,845
and then the last number will
be based on the router number.

26

00:03:11,383  -->  00:03:13,885
So here we can use n.

27

00:03:15,200  -->  00:03:17,154
Okay we have done here

28

00:03:17,772  -->  00:03:22,423
This append is used to add an item to the list,

29

00:03:23,337  -->  00:03:32,252
Here the list is empty, and then we do looping
from 2 to 5, and then we add the command

30

00:03:32,252  -->  00:03:38,617
to create interface loopback and configure the
ip address of interface loopback to the list.

31

00:03:39,680  -->  00:03:43,523
Oh ya, don’t forget to define the subnetmask here.

32

00:03:49,783  -->  00:03:54,000
Let’s try to print the
list_config, this is optional.

33

00:03:59,120  -->  00:04:08,834
Save, let’s back to the terminal, ls, here we
can see that we have netmiko_looping_nested.py,

34

00:04:09,475  -->  00:04:11,546
let’s execute this script.

35

00:04:16,366  -->  00:04:21,000
Here we can see the list
config, interface loopback2,

36

00:04:21,000  -->  00:04:31,428
the ip address is 10.3.3.1 255.255.255.255,
loopback3, the ip address is 10.4.4.1, and others.

37

00:04:32,480  -->  00:04:36,091
Here we can see that the
command is sent to the router1,

38

00:04:36,800  -->  00:04:38,673
Router 2 success,

39

00:04:40,328  -->  00:04:42,281
Router 3 success,

40

00:04:42,980  -->  00:04:47,885
Router 4 success, and router 5 also success.

41

00:04:48,823  -->  00:04:54,973
Okay so now we are success to configure
multiple interface on all router at once.

42

00:04:55,817  -->  00:04:58,274
I think enough for this video

43

00:04:58,594  -->  00:05:02,082
Thankyou for watching and see you on the next video.
